﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AISFMIOperator
{
     partial class EditInsurance : Form
    {

        private Patient curpatient;

        public EditInsurance()
        {
            InitializeComponent();            
        }

        public EditInsurance(Patient patient)
        {
            InitializeComponent();
            this.curpatient = patient;
        }

        private void InitFormData()
        {
            ownertype.Items.Clear();
            ownertype.Items.Add("Пациент");
            ownertype.Items.Add("Компания");

            ownertype.SelectedItem = ownertype.Items[0];

            if (this.patient != null)
            {
                patientsTable.AutoGenerateColumns = false;
                patientsTable.DataSource = patient;
                patientsTable.Columns[0].DataPropertyName = "FullName";
                patientsTable.Columns[1].DataPropertyName = "FullAddress";
                patientsTable.Columns[2].DataPropertyName = "ContactPhone";
                patientsTable.Columns[3].DataPropertyName = "Email";

                patientsTable.Enabled = false;
                patient.Enabled = false;
                addpat.Enabled = false;
                removepat.Enabled = false;
                viewpat.Enabled = false;
            }

        }

        private void EditInsurance_Load(object sender, EventArgs e)
        {

        }

        private void ownertype_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ownertype.SelectedIndex == 1)
            {
                ownertype.DataSource = Company.GetAllCompanies();
                ownertype.DisplayMember = "CompanyName";
            }
        }
    }
}
